package com.example.mechrevo.a3dtest;

import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

public class MainActivity extends AppCompatActivity{

    private MyGLSurfaceView myGLView;
    private RenderView myRenderer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        myGLView = findViewById(R.id.surfaceView);
        myGLView.setMyRenderer(myRenderer = new RenderView(this));
        load3DTask();
    }

    public void remove(View view){
        myRenderer.removeChild(0);
    }


    public void add(View v){
        myRenderer.addChildObj(this);
    }


    public void load3DTask(){
        new AsyncTask<Integer,String,String>() {
            @Override
            protected String doInBackground(Integer... integers) {
                myRenderer.addObject(MainActivity.this);
                return "0";
            }
            @Override
            protected void onPostExecute(String s) {
                super.onPostExecute(s);
                Log.v("===onPostExecute=====","ss="+s);
            }
        }.execute();
    }

    @Override
    protected void onPause() {
        super.onPause();
        myGLView.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        myGLView.onResume();
    }
}
